﻿<navigation:Page x:Class="LEEAAttendanceControl.Views.Overtime" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:my="clr-namespace:LEEAAttendanceControl.Web.Services"
           xmlns:converter="clr-namespace:LEEAAttendanceControl.Codes"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Overtime" xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices">
    <navigation:Page.Resources>
        <converter:MinutesToHoursConverter x:Key="MinutesToHours"/>
    </navigation:Page.Resources>

    <Grid x:Name="LayoutRoot">
        <ScrollViewer VerticalScrollBarVisibility="Auto">
            <StackPanel Orientation="Vertical">
                <Grid Background="#404041">
                    <TextBlock Text="Work Time" Foreground="White" FontSize="14" FontWeight="Bold" Margin="5,3,2,2"
                               HorizontalAlignment="Left"/>
                </Grid>
                
                <Grid HorizontalAlignment="Left" Margin="20,30,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="211"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    
                    <Grid.RowDefinitions>
                        <RowDefinition Height="28"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <riaControls:DomainDataSource Name="WorkTimeDataSource"  QueryName="GetWorkTimesSummary" AutoLoad="True" LoadingData="WorkTimeDataSource_LoadingData">
                        <riaControls:DomainDataSource.DomainContext>
                            <my:LEEAContext />
                        </riaControls:DomainDataSource.DomainContext>
                        <riaControls:DomainDataSource.SortDescriptors>
                            <riaControls:SortDescriptor PropertyPath="ID" Direction="Ascending" />
                        </riaControls:DomainDataSource.SortDescriptors>
                    </riaControls:DomainDataSource>
                    <sdk:DataGrid Name="WorkTimeEmployee" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" AutoGenerateColumns="False"  Height="Auto" ItemsSource="{Binding Data, ElementName=WorkTimeDataSource}" HeadersVisibility="All" VerticalContentAlignment="Stretch">
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTextColumn x:Name="DayNameCodeColumn" Binding="{Binding DayName}"
                                            IsReadOnly="True"    Header="Day" Width="60" />
                            <sdk:DataGridTemplateColumn CanUserReorder="True" Header="Time" CanUserResize="True" CanUserSort="True" >
                                <sdk:DataGridTemplateColumn.CellEditingTemplate>
                                    <DataTemplate >
                                        <toolkit:TimePicker Name="TimeColumn" Format="HH:mm" Value="{Binding Path=Time,Mode=TwoWay}" >
                                        </toolkit:TimePicker>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellEditingTemplate>
                            </sdk:DataGridTemplateColumn>
                        </sdk:DataGrid.Columns>

                    </sdk:DataGrid>

                </Grid>
                <Button x:Name="ApplyButton" Content="Apply" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="3"
                            Height="25" Width="65" HorizontalAlignment="Right" Margin="0,20,0,0" Click="ApplyButton_Click"/>

            </StackPanel>
        </ScrollViewer>
    </Grid>
</navigation:Page>
